package com.example.demo.controller;

import com.example.demo.modal.Sensor;
import com.example.demo.service.SensorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/sensor")
public class SensorController {
    @Autowired
    private SensorService sensorService;

    @GetMapping
    public String Table_Sensor(){
        return "sensor";
    }

    @PostMapping("/data")
    @ResponseBody
    public List<Sensor> Object_data(){
        return sensorService.findAll();
    }

    @PostMapping("/max")
    @ResponseBody
    public Integer Max_id(){return sensorService.SelectMaxId();}

    @PostMapping("/save")
    @ResponseBody
    public String save(@RequestBody Sensor sensor){
        sensorService.save(sensor);
        return "添加成功";
    }

    @PostMapping("/edit")
    @ResponseBody
    public String edit(@RequestBody Sensor sensor){
        sensorService.update(sensor);
        return "编辑成功";
    }

    @PostMapping("/delete")
    @ResponseBody
    public String delete(@RequestParam Integer id){
        sensorService.delete(id);
        return "删除成功";
    }

    @PostMapping("/find/sensoId")
    @ResponseBody
    public List<Sensor> find_sensoId(@RequestParam Integer id){
        System.out.println(id);
        return sensorService.findSensoId(id);
    }
    @PostMapping("/find/sensoCategory")
    @ResponseBody
    public List<Sensor> find_sensoCategory(@RequestParam String id){
        return sensorService.findSensoCategory(id);
    }
    @PostMapping("/find/sensoName")
    @ResponseBody
    public List<Sensor> find_sensoName(@RequestParam String id){
        return sensorService.findSensoName(id);
    }
    @PostMapping("/find/nameEngli")
    @ResponseBody
    public List<Sensor> find_nameEngli(@RequestParam String id){
        return sensorService.findNameEngli(id);
    }
    @PostMapping("/find/physiCount")
    @ResponseBody
    public List<Sensor> find_physiCount(@RequestParam Integer id){
        return sensorService.findPhysiCount(id);
    }
    @PostMapping("/find/physiQuantity1")
    @ResponseBody
    public List<Sensor> find_physiQuantity1(@RequestParam String id){
        return sensorService.findPhysiQuantity1(id);
    }
    @PostMapping("/find/physiQuantity2")
    @ResponseBody
    public List<Sensor> find_physiQuantity2(@RequestParam String id){
        return sensorService.findPhysiQuantity2(id);
    }
    @PostMapping("/find/physiQuantity3")
    @ResponseBody
    public List<Sensor> find_physiQuantity3(@RequestParam String id){
        return sensorService.findPhysiQuantity3(id);
    }
    @PostMapping("/find/sensoPrinc")
    @ResponseBody
    public List<Sensor> find_sensoPrinc(@RequestParam String id){
        return sensorService.findSensoPrinc(id);
    }
    @PostMapping("/find/sensoAccur")
    @ResponseBody
    public List<Sensor> find_sensoAccur(@RequestParam String id){
        return sensorService.findSensoAccur(id);
    }
    @PostMapping("/find/efficTime")
    @ResponseBody
    public List<Sensor> find_efficTime(@RequestParam String id){
        return sensorService.findEfficTime(id);
    }
    @PostMapping("/find/sensoAppli")
    @ResponseBody
    public List<Sensor> find_sensoAppli(@RequestParam String id){
        return sensorService.findSensoAppli(id);
    }
    @PostMapping("/find/sensoLimit")
    @ResponseBody
    public List<Sensor> find_sensoLimit(@RequestParam String id){
        return sensorService.findSensoLimit(id);
    }
    @PostMapping("/find/sensoWeigh")
    @ResponseBody
    public List<Sensor> find_sensoWeigh(@RequestParam String id){
        return sensorService.findSensoWeigh(id);
    }
    @PostMapping("/find/sensoVolum")
    @ResponseBody
    public List<Sensor> find_sensoVolum(@RequestParam String id){
        return sensorService.findSensoVolum(id);
    }
    @PostMapping("/find/sensoMater")
    @ResponseBody
    public List<Sensor> find_sensoMater(@RequestParam String id){
        return sensorService.findSensoMater(id);
    }
    @PostMapping("/find/costTime")
    @ResponseBody
    public List<Sensor> find_costTime(@RequestParam String id){
        return sensorService.findCostTime(id);
    }
    @PostMapping("/find/costMoney")
    @ResponseBody
    public List<Sensor> find_costMoney(@RequestParam String id){
        return sensorService.findCostMoney(id);
    }
}
